﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Micro.Core.ApiConsumer.ParameterAttributes;

namespace Micro.Core.ApiConsumer.Context
{
    /// <summary>
    /// 接口参数相关的描述类
    /// </summary>
    public class ApiParameterDescriptor:ICloneable
    {
        /// <summary>
        /// 参数名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 参数类型
        /// </summary>
        public Type ParameterType { get; set; }

        /// <summary>
        /// 参数拥有特性
        /// </summary>
        public ApiParameterAttribute ParameterAttribute { get; set; }

        /// <summary>
        /// 参数对应索引,用于获取参数值
        /// </summary>
        public int Index { get; set; }

        /// <summary>
        /// 参数值，先不赋值，便于参数描述对象缓存
        /// </summary>
        public object Value { get; set; }

        /// <summary>
        /// 克隆参数描述
        /// </summary>
        /// <returns></returns>
        public object Clone()
        {
            return new ApiParameterDescriptor
            {
                Name=this.Name,
                ParameterType=this.ParameterType,
                ParameterAttribute=this.ParameterAttribute,
                Index=this.Index,
                Value=null
            };
        }
    }
}
